package com.nondo.rdp.auth.endpoint.model;

import com.nondo.rdp.auth.domain.Role;
import com.nondo.rdp.core.common.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class RoleBean implements Serializable {
    private static final long serialVersionUID = -3861833947885360717L;
    private Long id;        // 编号
    private String name;    // 岗位名称
    private String enname;    //英文名称
    private Set<MenuBean> menuList = new HashSet<>(); // 拥有菜单列表

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEnname() {
        return enname;
    }

    public void setEnname(String enname) {
        this.enname = enname;
    }

    public Set<MenuBean> getMenuList() {
        return menuList;
    }

    public void setMenuList(Set<MenuBean> menuList) {
        this.menuList = menuList;
    }

    public List<Long> getMenuIdList() {
        List<Long> menuIdList = new ArrayList<>();
        for (MenuBean menu : menuList) {
            menuIdList.add(menu.getId());
        }
        return menuIdList;
    }

    public static RoleBean covert2Bean(Role role) {
        RoleBean roleBean = new RoleBean();
        BeanUtils.copy(role, roleBean);
        return roleBean;
    }

}
